package com.swjd.jingle.adapter;

import android.view.Gravity;

import androidx.fragment.app.FragmentActivity;

import com.swjd.jingle.pojo.MyType;
import com.xuexiang.xui.utils.DensityUtils;
import com.xuexiang.xui.widget.tabbar.vertical.TabAdapter;
import com.xuexiang.xui.widget.tabbar.vertical.TabView;

import java.util.List;

public class MyTabAdapter implements TabAdapter {
    private FragmentActivity context;
    private List<MyType> types;

    public MyTabAdapter(FragmentActivity context, List<MyType> types) {
        this.context = context;
        this.types = types;
    }

    @Override
    public int getCount() {
        return types.size();
    }

    @Override
    public TabView.TabBadge getBadge(int position) {
        return null;
    }

    @Override
    public TabView.TabIcon getIcon(int position) {
        return new TabView.TabIcon.Builder()
                .setIconGravity(Gravity.START)
                .setIconMargin(DensityUtils.dp2px(5))
                .setIconSize(DensityUtils.dp2px(20), DensityUtils.dp2px(20))
                .build();
    }

    @Override
    public TabView.TabTitle getTitle(int position) {
        return new TabView.TabTitle.Builder()
                .setContent(types.get(position).getTName())
                .setTextColor(0xFF36BC9B, 0xFF757575)
                .build();
    }

    @Override
    public int getBackground(int position) {
        return -1;
    }

}
